package com.example.kotlindemo


/**
 * 基类
 *
 * @author zhouronghua
 * @time 2021/6/7 6:11 PM
 */
open class Person(name:String) {

    /**
     * 姓名
     */
    var name:String = ""

    /**
     * 年龄
     */
    var age:Int = 0

    /**
     * 性别
     */
    var sex:String = ""
        get() = field  // filed指示为当前属性sex
        set(value) {
            field = value
        }

    /**
     * 次构造函数
     */
    constructor(name: String, age: Int) : this(name) {
        this.name = name
        this.age = age
    }

    /**
     * 类方法：toString
     */
    override fun toString(): String {
        return "Person(name='$name', age=$age, sex='$sex')"
    }
}